<template>
  <div>
    <!-- 订单财务审核-->
    <TopFilter :list="topFilterList" ref="top" :cols="3" @filterChange="changeHandle" @onCollapse="collapseHandle" :labelWidth="110" @resetChange="resetChange"></TopFilter>

    <Spin :spinning="exportLoading" tip="Loading...">
      <FilterTables
        ref="table"
        :columns="columns"
        :fetchapi="fetchApi"
        :params="fetchParams"
        :datakey="'records'"
        columnsRef="wkcOmOrderAuditConfirm"
        :isSelectColumn="true"
        :onRowSelectChange="selectChangeHandle"
        :onColumnsChange="(columns) => (this.columns = columns)"
      >
        <template slot="controls">
          <div
            :style="{
              paddingBottom: '10px',
            }"
          >
            <el-select v-model="value" clearable placeholder="请选择经销商" @change="changeDealer">
              <el-option v-for="item in options" :key="item.dealerCode" :label="item.dealerName" :value="item.dealerCode"> </el-option>
            </el-select>
            <multiuse-button size="small" type="primary" :click="addHandle.bind(this, 1)" :disabled="isOpen" style="margin-left: 10px">审核通过</multiuse-button>
            <multiuse-button size="small" type="primary" :click="addHandle.bind(this, 2)" :disabled="isOpen">作废</multiuse-button>
            <multiuse-button size="small" type="primary" :click="addHandle.bind(this, 3)" :disabled="isOpen">取消订单</multiuse-button>
          </div>
          <div
            :style="{
              textAlign: 'right',
            }"
          >
            <multiuse-button size="small" type="primary" :click="addHandle.bind(this, 4)">导 出</multiuse-button>
            <multiuse-button size="small" type="primary" :click="addHandle.bind(this, 5)">导入发运通知</multiuse-button>
            <multiuse-button size="small" type="primary" :click="addHandle.bind(this, 6)" :disabled="isOpen">资金调整</multiuse-button>
            <multiuse-button size="small" type="primary" :click="addHandle.bind(this, 7)" :disabled="isOpen">地址调整</multiuse-button>
            <multiuse-button size="small" type="primary" :click="addHandle.bind(this, 8)" :disabled="isOpen">保 存</multiuse-button>
          </div>
        </template>
      </FilterTables>
    </Spin>

    <BaseDialog :visible.sync="issearch" :title="'经销商查询'" destroyOnClose :containerStyle="{ height: 'calc(100% - 60px)', overflow: 'auto', paddingBottom: '60px' }">
      <ownerSeacher @close="dealercloseHandler" />
    </BaseDialog>
    <BaseDialog :visible.sync="isAddress" :title="'地址调整'" destroyOnClose :containerStyle="{ height: 'calc(100% - 60px)', overflow: 'auto', paddingBottom: '60px' }">
      <AddressAdjustment @close="AddressClose" :list="selectList" />
    </BaseDialog>
    <BaseDialog :visible.sync="isFundType" :title="'资金类型调整'" destroyOnClose :containerStyle="{ height: 'calc(100% - 60px)', overflow: 'auto', paddingBottom: '60px' }">
      <FundTypeAdjustment @close="FundTypeClose" :list="selectList" />
    </BaseDialog>
    <Drawer :visible.sync="detailVisible" :title="'订单信息'" :width="'80%'" destroyOnClose :containerStyle="{ height: 'calc(100% - 60px)', overflow: 'auto', paddingBottom: '60px' }">
      <detailModel :rowData="formData" @close="emitcloseHandler" />
    </Drawer>
    <BaseDialog :visible.sync="isreject" :title="'作废订单'" destroyOnClose :containerStyle="{ height: 'calc(100% - 60px)', overflow: 'auto', paddingBottom: '60px' }">
      <reject :list="selectList" @close="rejectClose" />
    </BaseDialog>
    <BaseDialog :visible.sync="isFinanceReject" :title="'作废订单'" destroyOnClose :containerStyle="{ height: 'calc(100% - 60px)', overflow: 'auto', paddingBottom: '60px' }">
      <FinanceReject :list="selectList" @close="financeRejectClose" />
    </BaseDialog>
    <BaseDialog :visible.sync="importVisible" :title="'导入'" destroyOnClose :containerStyle="{ height: 'calc(100% - 60px)', overflow: 'auto', paddingBottom: '60px' }">
      <importFiles @close="importcloseHandler" />
    </BaseDialog>
  </div>
</template>
<script>
import { getList, excelList, vehicleConfiguration, postconfirmPass, cancelOrder, saveList, getAllDealerList, allAccountType } from '@/api/omSale/OrderManagement/OrderAuditConfirm';
import detailModel from './detailModel';
import ownerSeacher from './ownerSeacher';
import reject from './reject';
import { dictionary } from '@/utils/dictMixin';
import { exportExcelFile } from '@/utils';
import { getAppId } from '@/assets/js/auth'; //获取登录用户
import { region } from '@/api/cms-common/region';
import { getSaleAreaInfo } from '@/api/cms-common/dealerdata/index';
import { dealerCommon } from '@/api/cms-api/origin/commonDealerType';
import AddressAdjustment from './AddressAdjustment';
import FundTypeAdjustment from './FundTypeAdjustment';
import importFiles from './importFiles';
export default {
  name: 'OrderFinancialAudit',
  data() {
    this.BaseTable = null;
    return {
      topFilterList: this.createdFrom(),
      columns: this.createdTable(),
      fetchApi: getList,
      fetchParams: {
        // xhrAbort: true
        isDealer: 10041002,
      },
      exportLoading: false,
      formData: {},
      issearch: false,
      detailVisible: false,
      selectList: [],
      isOpen: true,
      isreject: false,
      isAddress: false,
      isFundType: false,
      importVisible: false,
      options: [],
      value: '',
      areaList: [],
      isFinanceReject: false,
    };
  },
  components: {
    ownerSeacher,
    detailModel,
    reject,
    AddressAdjustment,
    FundTypeAdjustment,
    importFiles,
  },
  mixins: [dictionary, region, dealerCommon],
  mounted() {
    this.BaseTable = this.$refs.table.$refs.pageTable;
  },
  created() {
    this.getvehicleList();
    //初始化事业部下拉数据
    this.getAreaData();
    //初始化省份信息
    this.initProvince();
    this.getDealerList();
    this.initAllAccountType();
  },
  methods: {
    async getAreaData() {
      const res = await getSaleAreaInfo(15061013);
      if (res.resultCode === 200) {
        this.areaList = res.data;
        res.data.map((x) => {
          this.topFilterList.find((item) => item.fieldName == 'areaId').itemList.push({ text: x.orgName, value: x.id });
        });
      }
    },
    areaName(value) {
      for (let i in this.areaList) {
        if (this.areaList[i].id === value) {
          return this.areaList[i].orgName;
        }
      }
    },
    changeNum(index, data) {
      let discountAmount = 0;
      let sapPromotionPriceA = 0;
      let sapPromotionPriceB = 0;
      let sapServiceBonus = 0;
      let sapTerminalBonus = 0;
      let sapStandardPrice = 0;
      let singleRebateAmount = 0;
      let tryDriveDiscountRate = 0;
      discountAmount = Object.is(Number(data.discountAmount), NaN) ? 0 : Number(data.discountAmount);
      sapPromotionPriceA = Object.is(Number(data.sapPromotionPriceA), NaN) ? 0 : Number(data.sapPromotionPriceA);
      sapPromotionPriceB = Object.is(Number(data.sapPromotionPriceB), NaN) ? 0 : Number(data.sapPromotionPriceB);
      sapServiceBonus = Object.is(Number(data.sapServiceBonus), NaN) ? 0 : Number(data.sapServiceBonus);
      sapTerminalBonus = Object.is(Number(data.sapTerminalBonus), NaN) ? 0 : Number(data.sapTerminalBonus);
      singleRebateAmount = Object.is(Number(data.singleRebateAmount), NaN) ? 0 : Number(data.singleRebateAmount);
      sapStandardPrice = Object.is(Number(data.sapStandardPrice), NaN) ? 0 : Number(data.sapStandardPrice);
      tryDriveDiscountRate = Object.is(Number(data.tryDriveDiscountRate), NaN) ? 0 : Number(data.tryDriveDiscountRate);
      data.sapSettlementPrice =
        sapStandardPrice +
        sapServiceBonus +
        sapPromotionPriceB +
        sapPromotionPriceA +
        discountAmount +
        sapTerminalBonus +
        singleRebateAmount -
        (sapStandardPrice * (tryDriveDiscountRate / 100)).toFixed(2);
    },
    //加载所有资金类型
    async initAllAccountType() {
      const res = await allAccountType();
      if (res.resultCode === 200) {
        res.data.map((x) => {
          this.topFilterList.find((item) => item.fieldName == 'accountId').itemList.push({ text: x.accountTypeName, value: x.accountId });
        });
      }
    },
    changeDealer() {
      this.fetchParams = Object.assign({}, { dealerCode: this.value });
    },
    async getDealerList() {
      const res = await getAllDealerList();
      if (res.resultCode === 200) {
        this.options = res.data;
      }
    },
    importcloseHandler() {
      this.importVisible = false;
      this.fetchParams = Object.assign({}, this.fetchParams);
    },
    AddressClose(val) {
      if (val) {
        this.isOpen = true;
        this.fetchParams = Object.assign({}, this.fetchParams);
      }
      this.isAddress = false;
    },
    FundTypeClose(val) {
      if (val) {
        this.isOpen = true;
        this.fetchParams = Object.assign({}, this.fetchParams);
      }
      this.isFundType = false;
    },
    //初始化所在省份
    async initProvince() {
      let pl = this.createRegionList();
      this.topFilterList.find((item) => item.fieldName == 'provinceId').itemList = pl;
    },
    //初始化所在市数据
    async initCity(provinceId) {
      //清空市
      this.topFilterList.find((item) => item.fieldName == 'provinceId').initialValue = '';
      if (!provinceId || provinceId == null || typeof provinceId == 'undefined') {
        return;
      }
      //取省数据
      let rd = this.getRegionData();
      this.cityData = rd[provinceId].children;
      let cl = this.createSubRegionList(this.cityData);
      this.topFilterList.find((item) => item.fieldName == 'cityId').itemList = cl;
    },
    // 获取车型车系
    async getvehicleList() {
      let res = await vehicleConfiguration(0, { isUnlimited: 10041001 });
      this.topFilterList.find((item) => item.fieldName === 'brandProductList').itemList = res.data;
    },
    selectChangeHandle(row) {
      if (row.length > 0) {
        this.selectList = row || [];
        this.isOpen = false;
      } else {
        this.selectList = [];
        this.isOpen = true;
      }
    },
    seacherFun() {
      this.issearch = true;
    },
    async addHandle(type) {
      if (type == 1) {
        /* 审核通过 */
        let arr = [];
        for (let i in this.selectList) {
          //待审核和厂端取消可以继续审核
          if (this.selectList[i].orderStatus !== 24151001 && this.selectList[i].orderStatus !== 24151008) {
            arr.push(this.selectList[i].doNo);
          }
        }
        if (arr.length > 0) {
          this.$notify({
            title: '警告',
            message: '以下数据不能进行{' + arr + '}审核通过操作',
            type: 'warning',
          });
          return;
        }
        await this.$confirm('是否审核通过?请确认在审核前将数据进行保存操作', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning',
        })
          .then(async () => {
            this.exportLoading = true;
            let res = await postconfirmPass(this.selectList);
            this.exportLoading = false;
            if (res.resultCode == 200) {
              let total = res.data.total;
              let errorTotal = res.data.errorTotal;
              let error = res.data.error;
              this.$notify({
                title: '审核状态',
                message: '审核状态,审核' + total + '条,失败' + errorTotal + '条,失败列表' + error,
                type: 'success',
              });
              // this.$notify({
              //   title: '审核状态',
              //   message: '审核成功',
              //   type: 'success',
              // });
              this.isOpen = true;
              this.fetchParams = Object.assign({}, this.fetchParams);
            }
          })
          .catch(() => {
            this.exportLoading = false;
          });
      } else if (type == 2) {
        /* 作废 */
        let arr = [];
        if (this.selectList.length > 1) {
          this.$notify({
            title: '警告',
            message: '只能对单条数据作废操作',
            type: 'warning',
          });
          return;
        }
        for (let i in this.selectList) {
          //待审核和厂端取消可以进行作废
          if (this.selectList[i].orderStatus !== 24151001 && this.selectList[i].orderStatus !== 24151008) {
            arr.push(this.selectList[i].doNo);
          }
        }
        console.log(arr);
        if (arr.length > 0) {
          this.$notify({
            title: '警告',
            message: '以下数据不能进行{' + arr + '}作废操作',
            type: 'warning',
          });
          return;
        }
        if (this.selectList[0].firstFinanceCheckDate !== null && this.selectList[0].firstFinanceCheckDate !== '') {
          this.isFinanceReject = true;
        } else {
          this.isreject = true;
        }
      } else if (type == 3) {
        //取消订单 发到sap后才能取消
        let arr = [];
        for (let i in this.selectList) {
          //待审核和厂端取消可以继续审核
          if (!(this.selectList[i].orderStatus == 24151002 || this.selectList[i].orderStatus == 24151009)) {
            arr.push(this.selectList[i].doNo);
          }
        }
        console.log(arr);
        if (arr.length > 0) {
          this.$notify({
            title: '警告',
            message: '以下数据不能进行{' + arr + '}订单取消操作',
            type: 'warning',
          });
          return;
        }
        await this.$confirm('是否确定取消订单?', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning',
        })
          .then(async () => {
            this.exportLoading = true;
            let res = await cancelOrder(this.selectList);
            this.exportLoading = false;
            if (res.resultCode == 200) {
              let total = res.data.total;
              let errorTotal = res.data.errorTotal;
              let error = res.data.error;
              this.$notify({
                title: '取消状态',
                message: '取消状态：取消' + total + '条,失败' + errorTotal + '条,失败列表' + error,
                type: 'success',
              });
              // this.$notify({
              //   title: '取消状态',
              //   message: '取消成功',
              //   type: 'success',
              // });
              this.isOpen = true;
              this.fetchParams = Object.assign({}, this.fetchParams);
            }
          })
          .catch(() => {
            this.exportLoading = false;
          });
      } else if (type == 4) {
        //导出
        this.$confirm('是否将Excel表格保存至本地文件夹?', '提示', {
          confirmButtonText: '下载',
          cancelButtonText: '取消',
          type: 'warning',
        })
          .then(() => {
            this.$refs.top.SUBMIT_FORM();
            // this.exportLoading = true;
            excelList(this.fetchParams)
              .then((response) => {
                exportExcelFile(response.data, 'C端订单审核确认');
                // this.exportLoading = false;
              })
              .catch((err) => {
                console.log(err);
              });
          })
          .catch(() => {
            // this.exportLoading = false;
            this.$message({
              type: 'info',
              message: '已取消',
            });
          });
      } else if (type == 5) {
        /* 导入发运通知 */
        this.importVisible = true;
      } else if (type == 6) {
        /* 资金调整 */
        let array = [],
          data = {};
        this.selectList.map((x) => {
          data[x.dealerCode] = x.dealerCode;
        });
        for (let i in data) {
          array.push(data[i]);
        }
        if (array.length > 1) {
          this.$notify({
            title: '警告',
            message: '请选择同一经销商的数据',
            type: 'warning',
          });
          return;
        } else {
          let arr = [];
          for (let i in this.selectList) {
            if (this.selectList[i].orderStatus !== 24151001 && this.selectList[i].orderStatus !== 24151008) {
              arr.push(this.selectList[i].doNo);
            }
          }
          console.log(arr);
          if (arr.length > 0) {
            this.$notify({
              title: '警告',
              message: '以下数据不能进行{' + arr + '}资金调整操作',
              type: 'warning',
            });
            return;
          }
          this.isFundType = true;
        }
      } else if (type == 7) {
        /* 地址调整 */
        let array = [],
          data = {};
        this.selectList.map((x) => {
          data[x.dealerCode] = x.dealerCode;
        });
        for (let i in data) {
          array.push(data[i]);
        }
        if (array.length > 1) {
          this.$notify({
            title: '警告',
            message: '请选择同一经销商的数据',
            type: 'warning',
          });
          return;
        } else {
          let arr = [];
          for (let i in this.selectList) {
            if (this.selectList[i].orderStatus !== 24151001 && this.selectList[i].orderStatus !== 24151008) {
              arr.push(this.selectList[i].doNo);
            }
          }
          console.log(arr);
          if (arr.length > 0) {
            this.$notify({
              title: '警告',
              message: '以下数据不能进行{' + arr + '}地址调整操作',
              type: 'warning',
            });
            return;
          }
          this.isAddress = true;
        }
      } else if (type == 8) {
        /* 保存操作（待审核 厂端取消）*/
        let array1 = [];
        for (let i in this.selectList) {
          if (Number(this.selectList[i].tryDriveDiscountRate)>100 && Number(this.selectList[i].tryDriveDiscountRate) < 0) {
            array1.push(this.selectList[i].doNo);
          }
        }
        if (array1.length > 0) {
          this.$notify({
            title: '警告',
            message: '以下数据不能进行{' + array1 + '}保存操作,试乘试驾需设置为0-100',
            type: 'warning',
          });
          return;
        }
        let array = [];
        for (let i in this.selectList) {
          if (this.selectList[i].sapSettlementPrice < 0) {
            array.push(this.selectList[i].doNo);
          }
        }
        if (array.length > 0) {
          this.$notify({
            title: '警告',
            message: '以下数据不能进行{' + array + '}保存操作,结算价格不能小于0',
            type: 'warning',
          });
          return;
        }
        let arr = [];
        for (let i in this.selectList) {
          if (this.selectList[i].orderStatus !== 24151001 && this.selectList[i].orderStatus !== 24151008) {
            arr.push(this.selectList[i].doNo);
          }
        }
        if (arr.length > 0) {
          this.$notify({
            title: '警告',
            message: '以下数据不能进行{' + arr + '}保存操作',
            type: 'warning',
          });
          return;
        }
        await this.$confirm('是否保存选定的数据?', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning',
        })
          .then(async () => {
            this.exportLoading = true;
            let res = await saveList(this.selectList);
            this.exportLoading = false;
            if (res.resultCode == 200) {
              let total = res.data.total;
              let errorTotal = res.data.errorTotal;
              let error = res.data.error;
              this.$notify({
                title: '保存状态',
                message: '保存状态：保存' + total + '条,失败' + errorTotal + '条,失败列表' + error,
                type: 'success',
              });
              // this.$notify({
              //   title: '保存状态',
              //   message: '保存成功',
              //   type: 'success',
              // });
              this.isOpen = true;
              this.fetchParams = Object.assign({}, this.fetchParams);
            }
          })
          .catch(() => {
            this.exportLoading = false;
          });
      }
    },
    changeHandle(params) {
      this.isOpen = true;
      this.fetchParams.xhrAbort = false;
      this.fetchParams = Object.assign({}, this.fetchParams, params);
    },
    collapseHandle() {
      this.$nextTick(() => {
        this.BaseTable.EXECUTE_RESET_HEIGHT();
      });
    },
    editHandle(data) {
      this.formData = data;
      this.detailVisible = true;
    },
    emitcloseHandler(val) {
      if (val) {
        this.isOpen = true;
        this.fetchParams = Object.assign({}, this.fetchParams);
      }
      this.detailVisible = false;
    },
    rejectClose(val) {
      if (val) {
        this.isOpen = true;
        this.fetchParams = Object.assign({}, this.fetchParams);
      }
      this.isreject = false;
    },
    financeRejectClose(val) {
      if (val) {
        this.isOpen = true;
        this.fetchParams = Object.assign({}, this.fetchParams);
      }
      this.isFinanceReject = false;
    },
    dealercloseHandler(val, data) {
      if (data) {
        let dealerCodes = [];
        data.map((x) => {
          dealerCodes.push(x.dealerCode);
        });
        this.topFilterList.find((x) => x.fieldName == 'dealerCodes').initialValue = dealerCodes.toString();
      }
      this.issearch = false;
    },
    resetChange(val) {
      // this.topFilterList.map((x) => {
      //   if (x.fieldName == 'officeId') {
      //     x.itemList = [];
      //   }
      //   if (x.fieldName == 'orderStatus') {
      //     x.itemList = [];
      //   }
      // });
      this.fetchParams = Object.assign({}, this.fetchParams);
      this.value = null;
    },

    checkRow(checked, item) {
      console.log(`checked:${checked}`);
      console.log(`item:${item}`);
    },
    createdFrom() {
      return [
        {
          type: 'INPUT',
          label: '订单编号',
          fieldName: 'orderNo',
          placeholder: '请输入',
        },
        {
          type: 'INPUT',
          label: '物料编码',
          fieldName: 'productCode',
          placeholder: '请输入',
        },

        {
          type: 'SELECT',
          label: '订单类型',
          fieldName: 'orderType',
          placeholder: '请选择',
          itemList: this.createDictList('2410'),
        },
        {
          type: 'SELECT',
          label: '车辆用途',
          fieldName: 'vehicleUse',
          placeholder: '请选择',
          itemList: this.createDictList('2406'),
        },
        {
          type: 'SELECT',
          label: '紧急度',
          fieldName: 'emergencyType',
          placeholder: '请选择',
          itemList: this.createDictList('2101'),
        },
        {
          type: 'SELECT',
          label: '资金类型',
          fieldName: 'accountId',
          placeholder: '请选择',
          itemList: [],
        },
        {
          type: 'INPUT_CASCADER',
          label: '车型选择',
          fieldName: 'brandProductList',
          placeholder: '请选择',
          options: { titles: ['品牌', '车系', '车型', '配置', '选装', '颜色'] },
          itemList: [],
        },
        { type: 'SELECT', label: 'C端战区', fieldName: 'areaId', placeholder: '请选择', itemList: [] },
        {
          type: 'SELECT',
          label: '省份',
          fieldName: 'provinceId',
          placeholder: '请选择',
          itemList: [],
          change: (value) => {
            this.initCity(value);
          },
        },
        { type: 'SELECT', label: '城市', fieldName: 'cityId', placeholder: '请选择', itemList: [] },
        {
          type: 'INPUT',
          label: '经销商代码',
          fieldName: 'dealerCode',
          placeholder: '请输入',
        },
        {
          type: 'INPUT',
          label: '经销商名称',
          fieldName: 'dealerName',
          placeholder: '请输入',
        },
        {
          type: 'SELECT',
          label: '订单明细状态',
          fieldName: 'orderStatus',
          placeholder: '请选择',
          itemList: this.createDictList('2415'),
        },
        {
          type: 'TEXT_AREA',
          label: '订单管理号',
          fieldName: 'doNo',
          placeholder: '请输入',
          maxlength: '',
          maxRows: 2,
        },
      ];
    },
    createdTable() {
      return [
        {
          title: '序号',
          dataIndex: 'index',
          width: 80,
          sorter: true,
          fixed: 'left',
          render: (props) => {
            return <span>{props.row.index + 1}</span>;
          },
        },
        {
          title: '操作',
          dataIndex: 'column-action',
          width: 50,
          fixed: 'left',
          render: (props, h) => {
            return (
              <div>
                <multiuse-button size="mini" type="text" onClick={() => this.editHandle(props.row, 2)}>
                  详情
                </multiuse-button>
              </div>
            );
          },
        },
        {
          title: '是否最优先结算',
          dataIndex: 'firstPrioritySettle',
          sorter: true,
          filter: true,
          filterType: 'input',
          render: (p) => {
            return <el-checkbox disabled={true} checked={p.row.firstPrioritySettle === 10041001}></el-checkbox>;
          },
        },
        {
          title: '是否优先结算',
          dataIndex: 'prioritySettle',
          sorter: true,
          filter: true,
          filterType: 'input',
          render: (p) => {
            return <el-checkbox disabled={true} checked={p.row.prioritySettle === 10041001}></el-checkbox>;
          },
        },
        {
          title: '包销标记',
          dataIndex: 'underwriteFlag',
          sorter: true,
          filter: true,
          filterType: 'input',
          editable: true,
          defaultEditable: true,
          editType: 'checkbox',
          editItems: [
            { text: '', trueValue: 10041001 },
            { text: '', falseValue: 10041002 },
          ],
          onChange: (index, data) => {
            if (data.underwriteFlag === 10041001) {
              data.isNewRow = false;
              data.underwriteFlag = 10041002;
            } else {
              data.isNewRow = false;
              data.underwriteFlag = 10041001;
            }
          },
        },
        {
          title: 'C端战区',
          dataIndex: 'areaId',
          sorter: true,
          filter: true,
          filterType: 'input',
          render: (props) => {
            return <span>{this.areaName(props.row.areaId)}</span>;
          },
        },
        {
          title: '省份',
          dataIndex: 'provinceName',
          sorter: true,
          filter: true,
          filterType: 'input',
        },
        {
          title: '城市',
          dataIndex: 'cityName',
          sorter: true,
          filter: true,
          filterType: 'input',
        },
        {
          title: '经销商代码',
          dataIndex: 'dealerCode',
          sorter: true,
          filter: true,
          filterType: 'input',
        },
        {
          title: '经销商名称',
          dataIndex: 'dealerName',
          sorter: true,
          filter: true,
          filterType: 'input',
        },
        {
          title: '订单编号',
          dataIndex: 'orderNo',
          sorter: true,
          filter: true,
          filterType: 'input',
          align: 'center',
          width: 200,
        },
        {
          title: '订单管理号',
          dataIndex: 'doNo',
          sorter: true,
          filter: true,
          filterType: 'input',
          align: 'center',
          width: 200,
        },
        {
          title: '订单类型',
          dataIndex: 'orderType',
          sorter: true,
          filter: true,
          filterType: 'checkbox',
          filterItems: this.createDictList('2410'),
          render: (p) => {
            return <span>{this.createDictText(p.row.orderType, '2410')}</span>;
          },
        },
        {
          title: '紧急度',
          dataIndex: 'emergencyType',
          sorter: true,
          filter: true,
          filterType: 'input',
          render: (p) => {
            return <span>{this.createDictText(p.row.emergencyType, '2101')}</span>;
          },
        },
        {
          title: '车辆用途',
          dataIndex: 'vehicleUse',
          sorter: true,
          filter: true,
          filterType: 'input',
          render: (p) => {
            return <span>{this.createDictText(p.row.vehicleUse, '2406')}</span>;
          },
        },
        {
          title: '订单明细状态',
          dataIndex: 'orderStatus',
          sorter: true,
          filter: true,
          filterType: 'input',
          render: (p) => {
            return <span>{this.createDictText(p.row.orderStatus, '2415')}</span>;
          },
        },
        {
          title: '资金类型',
          dataIndex: 'accountId',
          sorter: true,
          filter: true,
          filterType: 'input',
          editable: true,
          editType: 'select',
          editRequired: true,
          width: 200,
          showOverflowTooltip: false,
          rules: [{ required: true, message: '请填写', trigger: 'blur' }],
          render: (p) => {
            return (
              <el-select
                size="mini"
                v-model={p.row.accountId}
                required
                placeholder="请选择"
                onChange={(value) => {
                  p.row.accountId = value;
                  // for (let x of p.row.accountTypes) {
                  //   if (x.accountId == value) {
                  //     p.row.ownFund = x.ownFund;
                  //     p.row.tripFund = x.tripFund;
                  //     break;
                  //   }
                  // }
                }}
              >
                {p.row.accountTypes.map((item) => (
                  <el-option key={item.accountId} label={item.accountTypeName} value={item.accountId} />
                ))}
              </el-select>
            );
          },
        },
        // {
        //   title: '自有资金金额',
        //   dataIndex: 'ownFund',
        //   sorter: true,
        //   filter: true,
        //   filterType: 'input',
        // },
        // {
        //   title: '三方可用余额',
        //   dataIndex: 'tripFund',
        //   sorter: true,
        //   filter: true,
        //   filterType: 'input',
        // },
        {
          title: '订单年月',
          dataIndex: 'orderYearMonth',
          sorter: true,
          filter: true,
          filterType: 'input',
        },
        {
          title: '运输方式',
          dataIndex: 'transportType',
          sorter: true,
          filter: true,
          filterType: 'input',
          render: (p) => {
            return <span>{this.createDictText(p.row.transportType, '2409')}</span>;
          },
        },
        {
          title: '收车地址',
          dataIndex: 'addressId',
          sorter: true,
          filter: true,
          filterType: 'input',
          editable: true,
          editType: 'select',
          editRequired: true,
          width: 200,
          showOverflowTooltip: false,
          rules: [{ required: true, message: '请填写', trigger: 'blur' }],
          render: (p) => {
            return (
              <el-select
                size="mini"
                v-model={p.row.addressId}
                required
                placeholder="请选择"
                onChange={(value) => {
                  p.row.addressId = value;
                }}
              >
                {p.row.addressDtos.map((item) => (
                  <el-option key={item.addressId} label={item.address} value={item.addressId} />
                ))}{' '}
              </el-select>
            );
          },
        },
        {
          title: '物料编码',
          dataIndex: 'productCode',
          sorter: true,
          filter: true,
          filterType: 'input',
        },
        {
          title: '物料描述',
          dataIndex: 'productName',
          align: 'center',
          width: 400,
          sorter: true,
          filter: true,
          filterType: 'input',
        },
        {
          title: '车系名称',
          dataIndex: 'seriesName',
          sorter: true,
          filter: true,
          filterType: 'input',
        },
        {
          title: '车型名称',
          dataIndex: 'modelName',
          sorter: true,
          filter: true,
          filterType: 'input',
        },
        {
          title: '配置',
          dataIndex: 'configName',
          sorter: true,
          filter: true,
          filterType: 'input',
        },
        {
          title: '选装',
          dataIndex: 'optionName',
          sorter: true,
          filter: true,
          filterType: 'input',
        },
        {
          title: '内饰',
          dataIndex: 'trimName',
          sorter: true,
          filter: true,
          filterType: 'input',
        },
        {
          title: '外饰',
          dataIndex: 'colorName',
          sorter: true,
          filter: true,
          filterType: 'input',
        },
        {
          title: '市场指导价',
          dataIndex: 'sapStandardPrice',
          sorter: true,
          filter: true,
          filterType: 'input',
          // editable: true,
          // editType: 'number',
          width: 120,
          // editRequired: true,
          precision: 2,
          // editPattern: /^[1-9]\d*$/,
          // defaultEditable: true,
          // rules: [{ required: true, message: '请填写正整数', trigger: 'blur' }],
          // onInput: (index, data) => {
          //   this.changeNum(index, data);
          // }
        },
        {
          title: '基础折扣',
          dataIndex: 'discountAmount',
          sorter: true,
          filter: true,
          filterType: 'input',
          editable: true,
          editType: 'number',
          editRequired: true,
          defaultEditable: true,
          precision: 2,
          onInput: (index, data) => {
            this.changeNum(index, data);
          },
        },
        {
          title: '终端奖',
          dataIndex: 'sapTerminalBonus',
          sorter: true,
          filter: true,
          filterType: 'input',
          precision: 2,
          editable: true,
          editType: 'number',
          editRequired: true,
          defaultEditable: true,
          onInput: (index, data) => {
            this.changeNum(index, data);
          },
        },
        {
          title: '优质服务奖',
          dataIndex: 'sapServiceBonus',
          sorter: true,
          filter: true,
          filterType: 'input',
          precision: 2,
          editable: true,
          editType: 'number',
          editRequired: true,
          defaultEditable: true,
          onInput: (index, data) => {
            this.changeNum(index, data);
          },
        },
        {
          title: '促销1',
          dataIndex: 'sapPromotionPriceA',
          sorter: true,
          filter: true,
          filterType: 'input',
          editable: true,
          editType: 'number',
          editRequired: true,
          defaultEditable: true,
          precision: 2,
          onInput: (index, data) => {
            this.changeNum(index, data);
          },
        },
        {
          title: '促销2',
          dataIndex: 'sapPromotionPriceB',
          sorter: true,
          filter: true,
          filterType: 'input',
          editable: true,
          editType: 'number',
          editRequired: true,
          defaultEditable: true,
          precision: 2,
          onInput: (index, data) => {
            this.changeNum(index, data);
          },
        },
        {
          title: '试乘试驾折扣（%）',
          dataIndex: 'tryDriveDiscountRate',
          sorter: true,
          filter: true,
          filterType: 'input',
          editable: true,
          editType: 'number',
          editRequired: true,
          defaultEditable: true,
          precision: 2,
          onInput: (index, data) => {
            this.changeNum(index, data);
          },
        },
        {
          title: '结算价格',
          dataIndex: 'sapSettlementPrice',
          sorter: true,
          filter: true,
          filterType: 'input',
          // editable: true,
          // editType: 'number',
          width: 100,
          // editRequired: true,
          precision: 2,
          // editPattern: /^[1-9]\d*$/,
          // defaultEditable: true,
          // rules: [{ required: true, message: '请填写正整数', trigger: 'blur' }],
          // onInput: (index, data) => {
          //   this.changeNum(index, data);
          // }
        },
        {
          title: '是否使用返利',
          dataIndex: 'isRebate',
          sorter: true,
          filter: true,
          filterType: 'checkbox',
          filterItems: this.createDictList('1004'),
          render: (p) => {
            return <span>{this.createDictText(p.row.isRebate, '1004')}</span>;
          },
        },
        {
          title: '返利使用金额',
          dataIndex: 'singleRebateAmount',
          sorter: true,
          filter: true,
          filterType: 'input',
          precision: 2,
        },

        {
          title: '提报时间',
          dataIndex: 'reportDate',
          sorter: true,
          filter: true,
          dateFormat: 'yyyy-MM-dd HH:mm:ss',
          filterType: 'date-range',
        },
        {
          title: '审核时间',
          dataIndex: 'checkDate',
          sorter: true,
          filter: true,
          dateFormat: 'yyyy-MM-dd HH:mm:ss',
          filterType: 'date-range',
        },
        {
          title: '作废原因',
          dataIndex: 'checkRamark',
          sorter: true,
          filter: true,
          filterType: 'input',
        },
        {
          title: '发运须知',
          dataIndex: 'deliveryRamark',
          sorter: true,
          filter: true,
          filterType: 'input',
          editable: true,
          editType: 'input',
          defaultEditable: true,
        },
        {
          title: '备注',
          dataIndex: 'remark',
          sorter: true,
          filter: true,
          filterType: 'input',
          editable: true,
          editType: 'input',
          defaultEditable: true,
        },
        {
          title: '审批报告编号',
          dataIndex: 'reportNo',
          sorter: true,
          filter: true,
          filterType: 'input',
          editable: true,
          editType: 'input',
          defaultEditable: true,
        },
      ];
    },
  },
};
</script>
<style lang="less">
</style>
